package com.chinacache.maint.workorder.entity;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.chinacache.maint.commons.entity.BaseEntity;

@Entity
@Table(name = "WO_WORKORDER")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class WorkOrder extends BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String name;
	private Set<WorkOrderStep> workOrderSteps = new LinkedHashSet<WorkOrderStep>(0);
	
	private String customer;
	private String user;
	private String memo;
	private String time;
	private FlowClass flowClass;

	@ManyToOne
	@JoinColumn(name = "FLOWCLASS_ID")
	public FlowClass getFlowClass() {
		return flowClass;
	}

	public void setFlowClass(FlowClass flowClass) {
		this.flowClass = flowClass;
	}

	@Column(name = "TIME")
	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	@Column(name = "MEMO")
	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	@OneToMany(mappedBy = "workOrder")
	@OrderBy("id")
	public Set<WorkOrderStep> getWorkOrderSteps() {
		return workOrderSteps;
	}

	public void setWorkOrderSteps(Set<WorkOrderStep> workOrderSteps) {
		this.workOrderSteps = workOrderSteps;
	}

	@Id
	@Column(name = "WORKORDER_ID")
	@GeneratedValue(generator = "SEQ_RPT_USER_TO_CLASS")
	@GenericGenerator(name = "SEQ_RPT_USER_TO_CLASS", strategy = "seqhilo", parameters = { @Parameter(name = "sequence", value = "SEQ_RPT_USER_TO_CLASS") })
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "NAME")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "CUSTOMER")
	public String getCustomer() {
		return customer;
	}

	public void setCustomer(String customer) {
		this.customer = customer;
	}

	@Column(name = "CCUSER")
	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

}
